﻿using Microsoft.WowAddonStudio.FrameXml.Serialization.LayoutFrames;
using NUnit.Framework;

namespace Microsoft.WowAddonStudio.FrameXml.Serialization.Tests
{
    [TestFixture]
    public class SimpleInheritanceTest : FrameXmlDirectoryTestBase
    {
        [Test]
        public void DefaultValueTest()
        {
            var button = new Button
                             {
                                 Name = "TestButton",
                                 Text = "OK"
                             };

            Assert.AreEqual(1.0f, button.Alpha);
        }

        [Test]
        public void ExplicitInheritanceTest()
        {
            var alphaButton = new Button
                                  {
                                      Name = "AlphaButton",
                                      Virtual = true,
                                      Alpha = 0.5f,
                                      Text = "AlphaButton"
                                  };

            // Explicitly create the relationship between the buttons
            var button = new Button
                             {
                                 Name = "TestButton",
                                 Text = "OK", 
                                 InheritedObject = alphaButton
                             };

            Assert.AreEqual("AlphaButton", button.Inherits);
            Assert.AreEqual(0.5f, button.Alpha);
            Assert.AreEqual("OK", button.Text);
        }

        [Test]
        public void ImplicitInheritanceTest()
        {
            var alphaButton = new Button
                                  {
                                      Name = "AlphaButton",
                                      Virtual = true,
                                      Alpha = 0.5f,
                                      Text = "AlphaButton"
                                  };

            // Implicitly create the relationship between the buttons by name
            var button = new Button
                             {
                                 Name = "TestButton",
                                 Text = "OK",
                                 Inherits = "AlphaButton"
                             };

            Assert.AreSame(alphaButton, button.InheritedObject);
            Assert.AreEqual(0.5f, button.Alpha);
            Assert.AreEqual("OK", button.Text);
        }
    }
}
